package com.bw.user.mvvm.view.fragment;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.bw.user.R;
import com.bw.user.mvvm.adapter.VpAdapter;
import com.bw.user.mvvm.fragment.OrderCanelFragment;
import com.bw.user.mvvm.fragment.OrderCompleteFragment;
import com.bw.user.mvvm.fragment.OrderListFragment;
import com.bw.user.mvvm.fragment.OrderPayFragment;
import com.bw.user.mvvm.fragment.OrderreceivingFragment;
import com.flyco.tablayout.SlidingTabLayout;
import com.google.android.material.tabs.TabLayout;

import java.util.ArrayList;
import java.util.List;

public class MyOrderActivity extends AppCompatActivity {

    private TabLayout Tab;
    private ViewPager VP;
    private LinearLayout orderGroupRoot;
    private ImageView orderGroupBackImg;
    private SlidingTabLayout orderGroupTab;
    private ViewPager orderGroupVp;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_order);
        initView();
        List<String> list = new ArrayList<>();
        list.add("全部");
        list.add("待付款");
        list.add("待收货");
        list.add("已完成");
        list.add("已取消");
        List<Fragment> fragments = new ArrayList<>();
        fragments.add(new OrderListFragment());
        fragments.add(new OrderPayFragment());
        fragments.add(new OrderreceivingFragment());
        fragments.add(new OrderCanelFragment());
        fragments.add(new OrderCompleteFragment());
        VpAdapter vpAdapter = new VpAdapter(getSupportFragmentManager(), fragments, list);
        orderGroupVp.setAdapter(vpAdapter);
        orderGroupTab.setViewPager(orderGroupVp);
        orderGroupBackImg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    private void initView() {

        orderGroupRoot = (LinearLayout) findViewById(R.id.order_group_root);
        orderGroupBackImg = (ImageView) findViewById(R.id.order_group_back_img);
        orderGroupTab = (SlidingTabLayout) findViewById(R.id.order_group_tab);
        orderGroupVp = (ViewPager) findViewById(R.id.order_group_vp);
    }
}